<?php
	global $_W,$_GPC;
	if($_W['role'] && $_W['isajax']){
		require_once MODULE_ROOT.'/mii/class/membercard.class.php';
		$mid = trim(intval($_GPC['mid']));
		$money = floatval($_GPC['money']);
		$validata = trim(intval($_GPC['validata']));
		if($validata !=1){exit(json_encode(array('status'=>-1,'msg'=>'验证失败')));}
		$data = array();
		$u = pdo_get('mii_ang_user',array('uid'=>$mid),array('openid'));
		$orderOn = date('YmdHis') . '00' . random(8,1);
		$on =  new memberNumber($mid);
		$mcard_on = $on->code_on();			
		$data = array(
					'uniacid' => $_W['uniacid'],
					'openid' => $u['openid'],
					'uniontid'=>$orderOn,
					'type' => 'recharge_mcard',	
					'pay_type'=>'ADMIN',		
					'fee' => $money,
					'mcard_on'=>$mcard_on,//待验证
					'status' => 1,
					'note'=>serialize(array('title'=>'会员卡充值','tmoney'=>$money)),
					'addtime'=>$_W['timestamp'],
				);		
		if($mid){
			$up = pdo_update('mii_ang_mcard',array('balance +='=>$money),array('uid'=>$mid));
			$inslog = pdo_insert('mii_ang_paylog',$data);
			if($up && $inslog){
				exit(json_encode(array('status'=>1,'msg'=>'成功充值:'. $money .'￥')));
			}else{
				exit(json_encode(array('status'=>-1,'msg'=>'写入数据失败')));
			}

		}else{
			exit(json_encode(array('status'=>-1,'msg'=>'缺失必要参数')));
		}
	}else{
		exit(json_encode(array('status'=>-1,'msg'=>'没有操作权限')));
	}

?>